package com.lcf.app.generator.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import com.lcf.app.generator.service.impl.UserServiceImpl;
import com.lcf.app.generator.model.entity.User;
import com.lcf.app.generator.other.UserDTO;
import com.lcf.app.generator.other.UserVO;
import com.lcf.common.web.Result;
import com.lcf.common.web.PageDTO;
import com.lcf.app.generator.common.BaseController;

import org.springframework.web.bind.annotation.RestController;



/**
 * <p>
 * 用户 前端控制器
 * </p>
 *
 * @author ChenFei
 * @since 2022-11-14
 */
@RestController
@RequestMapping("/user")
public class UserController extends BaseController<UserServiceImpl> {

    @GetMapping("/{id}")
    public Result<UserVO> getInfo(@PathVariable("id") String id) {
        return service.getInfo(id);
    }

    @PostMapping("")
    public Result<User> saveInfo(@RequestBody UserDTO dto) {
        return service.saveInfo(dto);
    }

    @PutMapping("")
    public Result<User> updateInfo(@RequestBody UserDTO dto) {
        return service.updateInfo(dto);
    }

    @DeleteMapping("/{id}")
    public Result<String> removeInfo(@PathVariable("id") String id) {
        return service.removeInfo(id);
    }

    @PostMapping("paging")
    public Result<Page<UserVO>> paging(@RequestBody PageDTO dto){
        return service.paging(dto);
    }

}
